PART 1

String x = "Hello";

1.) int y = x.length();
a. x = 3
b. x = 2
c. x = 5
d. x = 6

2.) int z = x.indexOf ("ll");
a. z = 3
b. z = 2
c. z = 4
d. z = 1

3.) int w = x.indexOf("he");
a. w = 1
b. w = -1
c. w = 2
d. w = 0

4.) int v = x.compareTo ("apple");
a. v = positive 1
b. v = 0
c. v = negative 1
d .none of the above

5.) int k = x.compareTo("Hello");
a. k = 0
b. k = negative 1
c. k = positive 1
d. none of the above

6.) String t = x.substring ("Hell");
a. Error
b. 0
c. 1
d. 2

7.) String t = x.substring(2);
a. t is "lo"
b. t is "ello"
c. t is "Hello"
d. t is "llo"

8.) String b = x.substring(2, 4);
a. b is "llo"
b. b is "ell"
c. b is "ll"
d. b is "el"

9.) int c = x.length;
a. 2
b.3
c.4
d. Error

10.) String u = x.substring ("2, 3");
a. error
b. u is " l "
c. u is "el "
d. u is " ell "

11.) int w = x.equals("ELLO");
a.True
b.False

12.) int a = x.substring(3);
a. a is "lo"
b. a is "llo"
c. a is "ello"
d. error



PART2

String x = "PRINCEWILLIAM_COUNTY"

1.) int y = x. length ();
a. 20
b. 21
c. 19
d. 22

2.) int t = x.indexOf (PRIN);
a. t = 0
b. t = 1
c. t = 2
d. Error

3.) String k = x.substring (2);
a. k = RINCEWILLIAMCOUNTY
b.k = RINCEWILLIAM_COUNTY
c. k = INCEWILLIAM_COUNTY
d.none of the above

4.) String q = x.substring(5, 17);
a. q = CEWILLIAM_COUNT
b. q = EWILLIAMCOUN
c. q = EWILLIAM_COU
d. q = CEWILLIAM_COUN

5.) int u = x.compareTo ("STRINGS");
a. negative 1
b. positive 1
c. 0
d. none of the above

6.) String g = x.substring("COUN");
a. g = 14
b. g = 13
c. Error
d. g = 13

7.) String c = x.substring(4).substring(5);
a. c= LIAM_COUNTY
b. c= CEWILLIAM_COUNTY
c. c = _COUNTY
d. c = ILLIAM_COUNTY

8.) int j = x.indexOf ("WILLIaM");
a. j = 6
b. j = 5
c. j = 4
d. j = -1

9.) int y = x.equals("PRINCEWILLIAM_COUNTY");
a.True
b.False
c. error

10.) int z = x.indexOf ("PRIN");
a. z = 0
b. z = 1
c. z = -1
d. z = 2

11.) String a = x.substring("2,8");
a. INCEWI
b. RINCEWI
c. INCEWIL
d. error

PART 3

string a = "infinity";

1.) int b = a.length() - 4;
b =

2.) int c = a.indexOf("ty") + b;
c =

3.) boolean d = !a.equals("infinity");
d =

4.) String e = a.substring(4);
e =

5.) String f = a.substring(1, 8);
f =

6.) boolean g = a.equals("infInity");
g =

7.) int h = a.indexOf("z");
h =

8.) int i = a.length() - b/g;
i =

9.) int j = a.substring(2);
j =

10.) int k = a.indexOf("ini") * c;
k =

PART4
string b = "FAIRFAX_COUNTY"
1.) int b = a.substring("3,7");
b =

2.) int c = a.length;
c =

3.) int d = a.equals("FAIRFAX");
d =

4.) int e = a.compareTo("Prince William");
e =

5.) int f = a.substring ("FAX");
f =

6.) int g = a.indexOf ("cow");
g =

7.) int h a.substring(3)substring(4);
h =

8.) int i a.length();
i =

9.) int j a.compareTo ("Apple")
i = 1

10.)string t = a.substring ("fair");
t =

PART 5
String meemee = "Rawr";

1.) int b = meemee.length( );
b =
2.) boolean c = meemee.compareTo("Raawr");
3.) int d = meemee.indexOf("Rawr");
4.) String e = meemee.indexOf("Rawr");
5.) boolean f = meemee.equals("Rawr.");
6.) boolean g = meemee.equals("Rawr");
7.) boolean h = meemee.equals("RaWr");
8.) int i = meemee.indexOf("r");
9.) String j = meemee.substring(0);
10.) String k = meemee.substring(4);

PART1 ANSWERS
1.) c
2.) b
3.) b
4.) a
5.) a
6.) a
7.) d
8.) c
9.) d
10.) b
11.) b
12.) d

PART 2 ANSWERS
1.) a
2.) d
3.) c
4.) c
5.) a
6.) c
7.) a
8.) d
9.) c
10.) a
11.) d

PART 3 ANSWERS
1.) 4
2.) 10
3.) false
4.) nity
5.) error (no 8th slot)
6.) false
7.) -1
8.) error
9.) finity
10.) 30

PART4 ANSWERS
1.) error
2.)error (need parenthesis)
3.) false
4.) -1
5.) error
6.) -1
7.) _COUNTY
8.) 14
9.) 1
10.) error (it should be index)

PART 5 ANSWERS__
1.) 4
2.) error
3.) 1
4.) error
5.) false
6.) true
7.) false
8.) 3
9.) Rawr
10.) error